from sqlalchemy import Column, Integer, String, SmallInteger, Text, Boolean
from sqlalchemy.dialects.mysql import DECIMAL
from mooc.db.database import Base


class McCreditsRecharge(Base):
    __tablename__ = 'ims_mc_credits_recharge'

    id = Column(Integer, primary_key=True, index=True)
    uniacid = Column(Integer, nullable=False)
    uid = Column(Integer, nullable=False)
    openid = Column(String(50), nullable=False)
    tid = Column(String(64), nullable=False)
    transid = Column(String(30), nullable=False)
    fee = Column(DECIMAL(10, 2), nullable=False)
    type = Column(String(15), nullable=False)
    tag = Column(String(10), nullable=False)
    status = Column(SmallInteger, nullable=False)
    createtime = Column(Integer, nullable=False)
    backtype = Column(SmallInteger, nullable=False)

class McCashRecord(Base):
    __tablename__ = 'ims_mc_cash_record'

    id = Column(Integer, primary_key=True, index=True)
    uniacid = Column(Integer, nullable=False)
    uid = Column(Integer, nullable=False)
    clerk_id = Column(Integer, nullable=False)
    store_id = Column(Integer, nullable=False)
    clerk_type = Column(SmallInteger, nullable=False)
    fee = Column(DECIMAL(10, 2), nullable=False)
    final_fee = Column(DECIMAL(10, 2), nullable=False)
    credit1 = Column(Integer, nullable=False)
    credit1_fee = Column(DECIMAL(10, 2), nullable=False)
    credit2 = Column(DECIMAL(10, 2), nullable=False)
    cash = Column(DECIMAL(10, 2), nullable=False)
    return_cash = Column(DECIMAL(10, 2), nullable=False)
    final_cash = Column(DECIMAL(10, 2), nullable=False)
    remark = Column(String(255), nullable=False)
    createtime = Column(Integer, nullable=False)
    trade_type = Column(String(20), nullable=False)

class McChatsRecord(Base):
    __tablename__ = 'ims_mc_chats_record'

    id = Column(Integer, primary_key=True, index=True)
    uniacid = Column(Integer, nullable=False)
    acid = Column(Integer, nullable=False)
    flag = Column(SmallInteger, nullable=False)
    openid = Column(String(32), nullable=False)
    msgtype = Column(String(15), nullable=False)
    content = Column(String(10000), nullable=False)
    createtime = Column(Integer, nullable=False)

class McMappingFans(Base):
    __tablename__ = 'ims_mc_mapping_fans'

    fanid = Column(Integer, primary_key=True, index=True, nullable=False)
    acid = Column(Integer, nullable=False)
    uniacid = Column(Integer, nullable=False)
    uid = Column(Integer, nullable=False)
    openid = Column(String(50), nullable=False)
    nickname = Column(String(50), nullable=False)
    groupid = Column(String(60), nullable=False)
    salt = Column(String(8), nullable=False)
    follow = Column(SmallInteger, nullable=False)
    followtime = Column(Integer, nullable=False)
    unfollowtime = Column(Integer, nullable=False)
    tag = Column(String(1000), nullable=False)
    updatetime = Column(Integer, nullable=True)
    unionid = Column(String(64), nullable=False)
    user_from = Column(SmallInteger, nullable=False)


class McMassRecord(Base):
    __tablename__ = 'ims_mc_mass_record'

    id = Column(Integer, primary_key=True, index=True, nullable=False)
    uniacid = Column(Integer, nullable=False)
    acid = Column(Integer, nullable=False)
    groupname = Column(String(50), nullable=False)
    fansnum = Column(Integer, nullable=False)
    msgtype = Column(String(10), nullable=False)
    content = Column(String(10000), nullable=False)
    group = Column(Integer, nullable=False)
    attach_id = Column(Integer, nullable=False)
    media_id = Column(String(100), nullable=False)
    type = Column(SmallInteger, nullable=False)
    status = Column(SmallInteger, nullable=False)
    cron_id = Column(Integer, nullable=False)
    sendtime = Column(Integer, nullable=False)
    finalsendtime = Column(Integer, nullable=False)
    createtime = Column(Integer, nullable=False)
    msg_id = Column(String(50), nullable=False)
    msg_data_id = Column(String(50), nullable=False)


class McCreditsRecord(Base):
    __tablename__ = 'ims_mc_credits_record'

    id = Column(Integer, primary_key=True, index=True)
    uid = Column(Integer, nullable=False)
    uniacid = Column(Integer, nullable=False)
    credittype = Column(String(10), nullable=False)
    num = Column(DECIMAL(10, 2), nullable=False)
    operator = Column(Integer, nullable=False)
    module = Column(String(30), nullable=False)
    clerk_id = Column(Integer, nullable=False)
    store_id = Column(Integer, nullable=False)
    clerk_type = Column(SmallInteger, nullable=False)
    createtime = Column(Integer, nullable=False)
    remark = Column(String(200), nullable=False)
    real_uniacid = Column(Integer, nullable=False)


class MCFansGroups(Base):
    __tablename__ = 'ims_mc_fans_groups'

    id = Column(Integer, primary_key=True, index=True)
    uniacid = Column(Integer, nullable=False)
    acid = Column(Integer, nullable=False)
    groups = Column(Text, nullable=False)


class McMembers(Base):
    __tablename__ = 'ims_mc_members'

    uid = Column(Integer, primary_key=True, index=True, nullable=False)
    uniacid = Column(Integer, nullable=False)
    mobile = Column(String(18), nullable=False)
    email = Column(String(50), nullable=False)
    password = Column(String(32), nullable=False)
    salt = Column(String(8), nullable=False)
    groupid = Column(Integer, nullable=False)
    credit1 = Column(DECIMAL(10, 2), nullable=False)
    credit2 = Column(DECIMAL(10, 2), nullable=False)
    credit3 = Column(DECIMAL(10, 2), nullable=False)
    credit4 = Column(DECIMAL(10, 2), nullable=False)
    credit5 = Column(DECIMAL(10, 2), nullable=False)
    credit6 = Column(DECIMAL(10, 2), nullable=False)
    createtime = Column(Integer, nullable=False)
    realname = Column(String(10), nullable=False)
    nickname = Column(String(20), nullable=False)
    avatar = Column(String(255), nullable=False)
    qq = Column(String(15), nullable=False)
    vip = Column(SmallInteger, nullable=False)
    gender = Column(SmallInteger, nullable=False)
    birthyear = Column(SmallInteger, nullable=False)
    birthmonth = Column(SmallInteger, nullable=False)
    birthday = Column(SmallInteger, nullable=False)
    constellation = Column(String(10), nullable=False)
    zodiac = Column(String(5), nullable=False)
    telephone = Column(String(15), nullable=False)
    idcard = Column(String(30), nullable=False)
    studentid = Column(String(50), nullable=False)
    grade = Column(String(10), nullable=False)
    address = Column(String(255), nullable=False)
    zipcode = Column(String(10), nullable=False)
    nationality = Column(String(30), nullable=False)
    resideprovince = Column(String(30), nullable=False)
    residecity = Column(String(30), nullable=False)
    residedist = Column(String(30), nullable=False)
    graduateschool = Column(String(50), nullable=False)
    company = Column(String(50), nullable=False)
    education = Column(String(10), nullable=False)
    occupation = Column(String(30), nullable=False)
    position = Column(String(30), nullable=False)
    revenue = Column(String(10), nullable=False)
    affectivestatus = Column(String(30), nullable=False)
    lookingfor = Column(String(255), nullable=False)
    bloodtype = Column(String(5), nullable=False)
    height = Column(String(5), nullable=False)
    weight = Column(String(5), nullable=False)
    alipay = Column(String(30), nullable=False)
    msn = Column(String(30), nullable=False)
    taobao = Column(String(30), nullable=False)
    site = Column(String(30), nullable=False)
    bio = Column(Text, nullable=False)
    interest = Column(Text, nullable=False)
    pay_password = Column(String(30), nullable=False)
    user_from = Column(SmallInteger, nullable=False)


class MCFansTag(Base):
    __tablename__ = 'ims_mc_fans_tag'

    id = Column(Integer, primary_key=True, index=True)
    uniacid = Column(Integer, nullable=True)
    fanid = Column(Integer, nullable=False)
    openid = Column(String(50), nullable=False)
    subscribe = Column(Integer, nullable=True)
    nickname = Column(String(100), nullable=True)
    sex = Column(Integer, nullable=True)
    language = Column(String(50), nullable=True)
    city = Column(String(50), nullable=True)
    province = Column(String(50), nullable=True)
    country = Column(String(50), nullable=True)
    headimgurl = Column(String(150), nullable=True)
    subscribe_time = Column(Integer, nullable=False)
    unionid = Column(String(100), nullable=True)
    remark = Column(String(250), nullable=True)
    groupid = Column(String(100), nullable=True)
    tagid_list = Column(String(250), nullable=True)
    subscribe_scene = Column(String(100), nullable=True)
    qr_scene_str = Column(String(250), nullable=True)
    qr_scene = Column(String(250), nullable=True)

class MCFansTagMapping(Base):
    __tablename__ = 'ims_mc_fans_tag_mapping'

    id = Column(Integer, primary_key=True, index=True)
    fanid = Column(Integer, nullable=False)
    tagid = Column(String(20), nullable=False)

class MCGroups(Base):
    __tablename__ = 'ims_mc_groups'

    groupid = Column(Integer, primary_key=True, index=True)
    uniacid = Column(Integer, nullable=False)
    title = Column(String(20), nullable=False)
    credit = Column(Integer, nullable=False)
    isdefault = Column(SmallInteger, nullable=False)

class MCHandsel(Base):
    __tablename__ = 'ims_mc_handsel'

    id = Column(Integer, primary_key=True, index=True)
    uniacid = Column(Integer, nullable=False)
    touid = Column(Integer, nullable=False)
    fromuid = Column(String(32), nullable=False)
    module = Column(String(30), nullable=False)
    sign = Column(String(100), nullable=False)
    action = Column(String(20), nullable=False)
    credit_value = Column(Integer, nullable=False)
    createtime = Column(Integer, nullable=False)

class McMemberAddress(Base):
    __tablename__ = 'ims_mc_member_address'

    id = Column(Integer, primary_key=True, index=True, nullable=False)
    uniacid = Column(Integer, nullable=False)
    uid = Column(Integer, nullable=False)
    username = Column(String(20), nullable=False)
    mobile = Column(String(11), nullable=False)
    zipcode = Column(String(6), nullable=False)
    province = Column(String(32), nullable=False)
    city = Column(String(32), nullable=False)
    district = Column(String(32), nullable=False)
    address = Column(String(512), nullable=False)
    isdefault = Column(Boolean, nullable=False)

class McMemberFields(Base):
    __tablename__ = 'ims_mc_member_fields'

    id = Column(Integer, primary_key=True, index=True, nullable=False)
    uniacid = Column(Integer, nullable=False)
    fieldid = Column(Integer, nullable=False)
    title = Column(String(255), nullable=False)
    available = Column(Boolean, nullable=False)
    displayorder = Column(SmallInteger, nullable=False)

class McMemberProperty(Base):
    __tablename__ = 'ims_mc_member_property'

    id = Column(Integer, primary_key=True, index=True, nullable=False)
    uniacid = Column(Integer, nullable=False)
    property = Column(String(200), nullable=False)


class McOauthFans(Base):
    __tablename__ = 'ims_mc_oauth_fans'

    id = Column(Integer, primary_key=True, index=True, nullable=False)
    oauth_openid = Column(String(50), nullable=False)
    acid = Column(Integer, nullable=False)
    uid = Column(Integer, nullable=False)
    openid = Column(String(50), nullable=False)
